<?php

namespace app\common\model;

/**
 * [Video  佛乐表]
 * @author [C。]
 * @return html
 */
class Video extends Base
{
    protected $name = 'video';
    /**
     * 根据搜索条件获取列表信息
     */
    public function getlist($map,$from = 0, $size = 5)
    {
        $order = ['n.id' => 'desc'];
        $join = [
            ['app_videocate c','n.itemid = c.id'],
        ];

        $result =  $this->field('c.cname,n.id,n.title,n.img,n.addtime,n.url,c.id itemid,n.states,n.play_num,n.jplay_num')
            ->alias('n')
            ->join($join)
            ->where($map)
            ->order($order)
            ->limit($from, $size)
            ->select();

        return $result;
    }

    /**
     * 搜索获取列表总数
     * @param array $param
     */
    public function getCount($map) {
        $join = [
            ['app_videocate c','n.itemid = c.id'],
        ];
        $result =  $this->alias('n')
            ->join($join)
            ->where($map)
            ->count();

        return $result;
    }
    /**
     * 根据搜索条件获取寺院列表信息
     */
    public function getlists($map,$from = 0, $size = 5)
    {
        $order = ['id' => 'desc'];
        $result =  $this->field('id,title,url,play_num,img,jplay_num,addtime')
            ->where($map)
            ->order($order)
            ->limit($from, $size)
            ->select();

        return $result;
    }
    /**
     * 搜索获取寺院列表总数
     * @param array $param
     */
    public function getCounts($map) {
        $result =  $this->where($map)->count();
        return $result;
    }
}